package com.morkalork.entities;

import java.awt.Point;

public class Brick 
{
	public final String BLUE_BRICK_URL = "/resources/BlueBrick.png";
	public final String GREEN_BRICK_URL = "/resources/GreenBrick.png";
	public final String RED_BRICK_URL = "/resources/RedBrick.png";
	public final String YELLOW_BRICK_URL = "/resources/YellowBrick.png";

	private Color m_Color;
	private Point m_OriginalPoint;
	private Point m_CurrentPoint;

	public Color getColor()
	{
		return m_Color;
	}
	public void setColor(Color m_Color)
	{
		this.m_Color = m_Color;
	}
	
	public Point getOriginalPoint()
	{
		return m_OriginalPoint;
	}
	
	public void setOriginalPoint(Point originalPoint)
	{
		m_OriginalPoint = originalPoint;
	}
	
	public Point getCurrentPoint()
	{
		return m_CurrentPoint;
	}
	
	public void setCurrentPoint(Point currentPoint)
	{
		m_CurrentPoint = currentPoint;
	}
	
	public Brick(Point position, Color color)
	{
		m_OriginalPoint = position;
		m_CurrentPoint = position;
		setColor(color);
	}
	
	public Brick(Point position)
	{
		m_OriginalPoint = position;
		m_CurrentPoint = position;
	}
	
	public String getColorUrl()
	{
		switch(getColor())
		{
			case RED:
				return RED_BRICK_URL;
			case BLUE:
				return BLUE_BRICK_URL;
			case GREEN:
				return GREEN_BRICK_URL;
			case YELLOW:
				return YELLOW_BRICK_URL;
		}
		
		throw new Error("Color not found!");
	}

	
	@Override
	public int hashCode() 
	{
		return m_CurrentPoint.hashCode();
	}
	 
	@Override
	public boolean equals(Object obj) 
	{
		if(obj == null)
		{
			return false;
		}
		
		Brick token = (Brick)obj;
		
		return m_CurrentPoint == token.getCurrentPoint();
	}
}
